<template>
    <van-nav-bar title="搜索" left-text="返回" left-arrow @click-left="() => { $router.push('/') }" fixed />
    <div style="height: 45px;"></div>
    <van-search v-model="searchval" placeholder="请输入搜索关键词" />
    <van-skeleton v-show="gjp" title :row="10" />
    <van-cell-group v-for="item in qsearchApiData">
        <van-cell :title="item.goods_name" />
    </van-cell-group>
    <div class="status">

    </div>
    <van-empty v-show="kongstatus" image="https://fastly.jsdelivr.net/npm/@vant/assets/custom-empty-image.png" image-size="80"
        description="描述文字" />
</template>

<script setup>
import { qsearchApi } from '@/api/api';
import _ from 'lodash';
import { ref,watch } from 'vue';
let qsearchApiData = ref([])
let searchval = ref('')
let status=ref(true)
let gjp=ref(false)
let kongstatus=ref(false)
watch(searchval,_.debounce(val=>{
    if(val.length==0){
        status.value=true
        kongstatus.value=false
    }else{
        status.value=false
        qsearchApi(val).then(res=>{
            gjp.value=true
            qsearchApiData.value=res.data.message
            if(res.data.message.length==0){
                kongstatus.value=true
            }else{
                kongstatus.value=false
            }
        })
    }
},3000))
setInterval(()=>{
    gjp.value=false
},2000)
</script>

<style lang="scss" scoped></style>